/* 
 * 
 * Copyright 2011 The University of Adelaide
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License. 
 *  
 */

package au.org.aekos.ands.global.populate;

import java.util.Map;

import au.org.aekos.ands.global.Schema.EntityType;
import au.org.aekos.ands.global.Schema.Field;
import au.org.aekos.ands.global.parse.PropertyParser;
import au.org.ands.standards.rifCs.registryObjects.CollectionDocument.Collection;
import au.org.ands.standards.rifCs.registryObjects.DescriptionType;
import au.org.ands.standards.rifCs.registryObjects.IdentifierType;
import au.org.ands.standards.rifCs.registryObjects.LocationType;
import au.org.ands.standards.rifCs.registryObjects.NameType;
import au.org.ands.standards.rifCs.registryObjects.RelatedInfoType;
import au.org.ands.standards.rifCs.registryObjects.SubjectType;

public class PopulateCollection extends Populate<Collection> {
	public PopulateCollection(Map<Field, PropertyParser<?>> parsers) {
		super(EntityType.COLLECTION, parsers);
	}
	
	@Override
	public void populate(Collection collection, Field field, String identifier) {
		switch (field) {
		case IDENTIFIER:
			collection.setIdentifierArray((IdentifierType[])getMetadata(Field.IDENTIFIER, identifier));
			break;
		case NAME:
			collection.setNameArray((NameType[])getMetadata(Field.NAME, identifier));
			break;
		case LOCATION:
			collection.setLocationArray((LocationType[])getMetadata(Field.LOCATION, identifier));
			break;
		case DESCRIPTION:
			collection.setDescriptionArray((DescriptionType[])getMetadata(Field.DESCRIPTION, identifier));
			break;
		case SUBJECT:
			collection.setSubjectArray((SubjectType[])getMetadata(Field.SUBJECT, identifier));
			break;
		case RELATED:
			collection.setRelatedInfoArray((RelatedInfoType[])getMetadata(Field.RELATED, identifier));
			break;
		}
	}
}
